﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyMainSite2.Data.Repositories
{
	public class PageRepository : IPageRepository
	{
		#region Public Methods

		public tblPage GetPageByName(string name)
		{
			if (String.IsNullOrWhiteSpace(name))
				return null;

			var context = new MyMainSite2Entities();

			var page = (from p in context.tblPages
						where p.Name == name
						select p).SingleOrDefault();

			return page;
		}

		public tblPage GetPageByUrl(string url)
		{
			if (String.IsNullOrWhiteSpace(url))
				return null;

			var context = new MyMainSite2Entities();

			var page = (from p in context.tblPages
						where p.tblUrl.Url == url
						select p).SingleOrDefault();

			return page;
		}

		#endregion
	}
}
